refactor: consolidate agent configurations and improve test coverage#1712
refactor: consolidate agent configurations and improve test coverage#1712neelneelpurk wants to merge 2 commits intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the AI agent configuration system by consolidating agent metadata into a single source of truth (src/specify_cli/agent_config.py), eliminating duplication between __init__.py and extensions.py. The refactoring improves maintainability by ensuring consistent configuration across the CLI initialization and extension registration systems.
Changes:
- Created
agent_config.pyas the single source of truth for all agent metadata, including newly added fields for command format, args, and extension - Updated
extensions.pyto dynamically generateCommandRegistrar.AGENT_CONFIGSfrom the shared configuration with improved internal field naming - Expanded test coverage with parametrized tests that verify command registration for all 18 configured agents (including AGY/Antigravity)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/agent_config.py |
New file defining AGENT_CONFIG dictionary with comprehensive agent metadata including command format specifications |
src/specify_cli/__init__.py |
Removed duplicate AGENT_CONFIG definition and imports from new agent_config module |
src/specify_cli/extensions.py |
Updated to import and dynamically transform AGENT_CONFIG into AGENT_CONFIGS, renamed internal fields (format→command_format, args→command_args, extension→command_extension) |
tests/test_extensions.py |
Enhanced with parametrized tests covering all agents for command registration and alias handling |
AGENTS.md |
Updated documentation to reference new config location and document new field names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@neelneelpurk Can you please resolve Run uvx ruff check src/ Found 1 error. |
@mnriem Resolved this in my latest commit d26c592 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
src/specify_cli/agent_config.py:106
auggieis configured withcommands_subdir: "rules", so extension commands will be registered into.augment/rules. The template packaging script currently creates.augment/commandsfor Auggie command files (.github/workflows/scripts/create-release-packages.sh:197-199). Please align these, otherwise extensions will register commands into a directory the generated project layout may not use.
"auggie": {
"name": "Auggie CLI",
"folder": ".augment/",
"commands_subdir": "rules",
"install_url": "https://docs.augmentcode.com/cli/setup-auggie/install-auggie-cli",
src/specify_cli/agent_config.py:136
roois configured withcommands_subdir: "rules", which routes extension command registration to.roo/rules. The release template packaging script currently creates.roo/commandsfor Roo command files (.github/workflows/scripts/create-release-packages.sh:200-202). Please align these so extensions register commands where Roo projects actually load them.
"roo": {
"name": "Roo Code",
"folder": ".roo/",
"commands_subdir": "rules",
"install_url": None,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "kilocode": { | ||
| "name": "Kilo Code", | ||
| "folder": ".kilocode/", | ||
| "commands_subdir": "rules", |
There was a problem hiding this comment.
kilocode uses commands_subdir: "rules", which makes extension command registration write into .kilocode/rules. However the release template packaging script currently creates .kilocode/workflows for commands (see .github/workflows/scripts/create-release-packages.sh:194-196). These need to be aligned (either update this config or the packaging script), otherwise specify extension add will register commands into a directory that the Kilocode template/agent won’t read.
This issue also appears in the following locations of the same file:
- line 102
- line 132
| "commands_subdir": "rules", | |
| "commands_subdir": "workflows", |
| @pytest.mark.parametrize("agent_id, config", CommandRegistrar.AGENT_CONFIGS.items()) | ||
| def test_register_commands_for_each_agent(self, agent_id, config, extension_dir, project_dir): | ||
| """Test registering commands for all agents.""" | ||
| # Create agent directory | ||
| agent_dir = project_dir / config["dir"] | ||
| agent_dir.mkdir(parents=True) |
There was a problem hiding this comment.
These tests now iterate over CommandRegistrar.AGENT_CONFIGS, which is derived directly from AGENT_CONFIG. That makes the assertions somewhat tautological: if AGENT_CONFIG has an incorrect command directory (e.g. .kilocode/...), the tests will still pass because they create whatever directory the config says. Consider adding at least one assertion that checks specific known agent directories (or validates against the template packaging source) so the suite can actually detect configuration drift.
| @@ -69,6 +69,9 @@ AGENT_CONFIG = { | |||
| "commands_subdir": "commands", # Subdirectory name for command files (default: "commands") | |||
| "install_url": "https://example.com/install", # URL for installation docs (or None if IDE-based) | |||
| "requires_cli": True, # True if CLI tool required, False for IDE-based agents | |||
| "command_format": "markdown", # File format for commands (markdown/toml) | |||
| "command_args": "$ARGUMENTS", # Placeholder for arguments | |||
| "command_extension": ".md", # File extension for commands | |||
There was a problem hiding this comment.
Since this doc now states src/specify_cli/agent_config.py is the single source of truth, the “Current Supported Agents” table above should match the directories in AGENT_CONFIG. Right now the table/explanatory text has conflicting examples (e.g. Codex listed as .codex/commands/ vs AGENT_CONFIG['codex']['commands_subdir'] = 'prompts'). Please reconcile the table/examples with the new config to avoid sending contributors to the wrong paths.
| # Agent configurations with directory, format, and argument placeholder | ||
| AGENT_CONFIGS = { | ||
| "claude": { | ||
| "dir": ".claude/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "gemini": { | ||
| "dir": ".gemini/commands", | ||
| "format": "toml", | ||
| "args": "{{args}}", | ||
| "extension": ".toml" | ||
| }, | ||
| "copilot": { | ||
| "dir": ".github/agents", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "cursor": { | ||
| "dir": ".cursor/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "qwen": { | ||
| "dir": ".qwen/commands", | ||
| "format": "toml", | ||
| "args": "{{args}}", | ||
| "extension": ".toml" | ||
| }, | ||
| "opencode": { | ||
| "dir": ".opencode/command", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "windsurf": { | ||
| "dir": ".windsurf/workflows", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "kilocode": { | ||
| "dir": ".kilocode/rules", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "auggie": { | ||
| "dir": ".augment/rules", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "roo": { | ||
| "dir": ".roo/rules", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "codebuddy": { | ||
| "dir": ".codebuddy/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "qodercli": { | ||
| "dir": ".qoder/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "q": { | ||
| "dir": ".amazonq/prompts", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "amp": { | ||
| "dir": ".agents/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "shai": { | ||
| "dir": ".shai/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| }, | ||
| "bob": { | ||
| "dir": ".bob/commands", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md" | ||
| agent_id: { | ||
| "dir": f"{cfg['folder']}{cfg['commands_subdir']}", | ||
| "command_format": cfg["command_format"], | ||
| "command_args": cfg["command_args"], | ||
| "command_extension": cfg["command_extension"] |
There was a problem hiding this comment.
The comment above AGENT_CONFIGS still refers to generic format/args/extension, but the keys have been renamed to command_format/command_args/command_extension. Updating the comment will reduce confusion when maintaining this mapping.
mnriem
left a comment
There was a problem hiding this comment.
Please pull latest from upstream main, resolve conflicts and address Copilot feedback
Summary
This PR refactors the AI agent configuration system to eliminate duplication, reduce the risk of configuration drift, and improve maintainability. It also enhances the test suite to ensure consistent command registration across all supported agents.
Changes
Consolidated Configuration: Moved the agent metadata from
src/specify_cli/__init__.pyto a new dedicated file:src/specify_cli/agent_config.py.Dynamic Registry: Updated
src/specify_cli/extensions.pyto dynamically generate theCommandRegistrar.AGENT_CONFIGSregistry from the shared source of truth.Improved Internal Naming: Renamed internal configuration keys to be more descriptive and avoid namespace collisions:
"format"→"command_format""args"→"command_args""extension"→"command_extension"Generic Command Registration: Updated
src/specify_cli/extensions.pyto use a generic registration flow that works for all agents without special-case logic.Expanded Test Coverage: Updated
tests/test_extensions.pyusing@pytest.mark.parametrizeto loop through every supported agent (includingagy,codex,gemini, etc.) to verify command and alias registration.Updated Documentation: Refactored
AGENTS.mdto point developers to the new configuration location and reflect the updated field names.Impact
src/specify_cli/agent_config.py.Testing
uv run specify --helpuv sync && uv run pytestAI Disclosure
Used Antigravity for code generation and review.
Issue
Fixes #1705